package main

import "fmt"

func foundOnceNumber(arr []int, k int) int {
	// write code here

	n := int32(0)
	ans := make([]int, 32, 32)
	for i := 31; i >= 0; i-- {
		for j := 0; j < len(arr); j++ {
			if int32(arr[j])&(1<<i) != 0 {
				ans[i]++
			}
		}
		ans[i] %= k
		n = 2*n + int32(ans[i])
	}
	//fmt.Println(ans)

	return int(n)
}

func main() {
	res := foundOnceNumber([]int{-5, -4, 1, 1, -5, 1, -5}, 3)
	fmt.Println(res)
}
